<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li ><a href="{:url('Gift/index')}">礼物列表</a></li>
			<li class="active"><a >{:lang('EDIT')}</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('Gift/editPost')}">
            <div class="form-group">
				<label for="input-type" class="col-sm-2 control-label"><span class="form-required">*</span>类型</label>
				<div class="col-md-6 col-sm-10" id="type">
                    <volist name="type" id="v">
					<label class="radio-inline"><input type="radio" name="type" value="{$key}" <if condition="$key eq $data['type']">checked</if>>{$v}</label>
                    </volist>
				</div>
			</div>
            
            <div class="form-group">
				<label for="input-mark" class="col-sm-2 control-label"><span class="form-required">*</span>标识</label>
				<div class="col-md-6 col-sm-10" id="mark" style="position: relative;" id="mark">
                    <volist name="mark" id="v">
					<label class="radio-inline" for="mark_{$key}"><input type="radio" name="mark" value="{$key}" id="mark_{$key}" <if condition="$key eq $data['mark']">checked</if> <if condition="$data['type'] eq 1 && $key==3">disabled</if>>{$v}</label>
                    </volist>
                    <div id="tips" style="position: absolute;left: 450px;top: 0;<if condition="$data['mark'] neq '3'">display:none;</if>">
                        <span style="color:#ff0000">幸运礼物说明</span><br>
                        1.用户送出去幸运礼物时，幸运礼物的价值将分成三份，分别为主播、奖池和平台，后台可以设置主播和奖池获得的比例，剩下的归属于平台，主播和奖池的比例不要超过100%【谨记】<br>
                        2.后台可设置某个礼物为幸运礼物<br>
                        3.成为幸运礼物后，可设置幸运礼物的的中奖设置以及奖池设置，以下是幸运礼物和奖池说明<br>
                            a)在中奖设置中可设置每个礼物每组每个倍数的中奖概率【如：小黄瓜 每组送10个中10倍的概率为 5%，小黄瓜 每组送100个中10倍的概率为 <br>6%】，当用户中奖后，返还的奖励以当组礼物总价值为基数返还【如送了一组10个的，总价值为100，中了10倍，那么会获得1000钻石】<br>
                            b)奖池说明：奖池分为三个阶段，后台可设置每个奖池的金额下限，直接当奖池里边的金额达到最低的金额限制时，奖池才会开启，当有用户中奖时，会赢走奖池内的所有奖金<br>
                            c)幸运礼物与奖池说明：后台可设置每个幸运礼物每个组数相对于奖池每个阶段的中奖概率【如：小黄瓜每组10个对于奖池1阶段的中奖概率为0.01%，】，建议设置：礼物价值越高中奖概率越高，每组数量越多中奖概率越大<br>
                    </div>
				</div>
			</div>
            
            <div class="form-group">
				<label for="input-giftname" class="col-sm-2 control-label"><span class="form-required">*</span>名称</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-name" name="giftname" value="{$data['giftname']}" style="width:300px;">
				</div>
			</div>
            
            <div class="form-group">
				<label for="input-needcoin" class="col-sm-2 control-label"><span class="form-required">*</span>价格</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-needcoin" name="needcoin" value="{$data['needcoin']}" style="width:300px;">
				</div>
			</div>
            
            <div class="form-group">
				<label for="input-user_login" class="col-sm-2 control-label"><span class="form-required">*</span>图片</label>
				<div class="col-md-6 col-sm-10">
					<input type="hidden" name="gifticon" id="thumbnail" value="{$data['gifticon']}">
                    <a href="javascript:uploadOneImage('图片上传','#thumbnail');">
                        <if condition="empty($data.gifticon)">
                        <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                 id="thumbnail-preview"
                                 style="cursor: pointer;max-width:100px;max-height:100px;"/>
                        <else/>
                        <img src="{:get_upload_path($data.gifticon)}"
                             id="thumbnail-preview"
                             style="cursor: pointer;max-width:100px;max-height:100px;"/>
                        </if>
                    </a>
                    <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片"> 
                    <p class="help-block">建议尺寸： 50 X 50 太大会造成加载图片加载慢等各种问题</p>
				</div>
			</div>
			
			
			<div id="swf_area" <if condition="$data['type'] eq '3' or $data['type'] eq '0'">style="display: none;"</if> >
            
                <div class="form-group">
    				<label for="input-swftype" class="col-sm-2 control-label"><span class="form-required">*</span>动画类型</label>
    				<div class="col-md-6 col-sm-10" id="swftype">
                        <volist name="swftype" id="v">
    					<label class="radio-inline"><input type="radio" name="swftype" value="{$key}" <if condition="$key eq $data['swftype']">checked</if>>{$v}</label>
                        </volist>
    				</div>
    			</div>

                <if condition="$data['type'] eq '1' and $data['swftype'] eq '1'">
                    <!-- svga播放区域 -->
                    <div class="form-group">
                        <label for="input-gif" class="col-sm-2 control-label">svga动画</label>
                        <div class="col-md-6 col-sm-10">
                            <div id="demoCanvas" style="width: 200px;height: 300px;"></div>
                        </div>
                    </div>
                </if>
            
                <div class="form-group" id="">
    				<label for="input-gif" class="col-sm-2 control-label">上传图片</label>
    				<div class="col-md-6 col-sm-10">
                        <div id="swftype_bd_0" <if condition="$data['swftype'] eq '1'">style="display:none;"</if>>
                            <input type="hidden" name="gif" id="thumbnail2" value="{$data['swf']}">
                            <a href="javascript:uploadOneImage('图片上传','#thumbnail2');">
                                <if condition="empty($data.swf) || $data['swftype'] eq '1'">
                                <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                         id="thumbnail2-preview"
                                         style="cursor: pointer;max-width:100px;max-height:100px;"/>
                                <else/>
                                <img src="{:get_upload_path($data.swf)}"
                                     id="thumbnail2-preview"
                                     style="cursor: pointer;max-width:100px;max-height:100px;"/>
                                </if>
                            </a>
                            <input type="button" class="btn btn-sm btn-cancel-thumbnail2" value="取消图片"> <p class="help-block">建议尺寸： 200 X 200</p>
                        </div>
                        <div id="swftype_bd_1" <if condition="$data['swftype'] eq '0'">style="display:none;"</if>>
                            <input class="form-control" id="js-file-input" type="text" name="svga" value="{$data['swf']}" style="width: 300px;display: inline-block;" title="文件名称">
                            <a href="javascript:uploadOne('文件上传','#js-file-input','file');">上传SVGA文件</a>
                        </div>
                        
    				</div>
    			</div>
            
                <div class="form-group">
    				<label for="input-swftime" class="col-sm-2 control-label">动画时长</label>
    				<div class="col-md-6 col-sm-10">
    					<input type="text" class="form-control" id="input-swftime" name="swftime" value="{$data['swftime']}" style="width:300px;">
                        <p class="help-block">秒 精度：小数点后两位</p>
    				</div>
    			</div>
			
			</div>
            

            <div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="hidden" name="id" value="{$data.id}" />
                    <input type="hidden" name="gifticon_old" value="{$data['gifticon']}">
                    <input type="hidden" name="svga_old" value="{$data['swf']}">
                    <input type="hidden" name="gif_old" value="{$data['swf']}">
					<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('EDIT')}</button>
					<a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
				</div>
			</div>

		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
    <script src="__STATIC__/js/svga.min.js"></script>
    <script type="text/javascript">
        (function(){
            $('.btn-cancel-thumbnail').click(function () {
                $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
                $('#thumbnail').val('');
            });
            
            $('.btn-cancel-thumbnail2').click(function () {
                $('#thumbnail2-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
                $('#thumbnail2').val('');
            });
            $("#type label input").on('click',function(){
                var v=$(this).val();
                if(v==0){
                    $("#mark_3").removeAttr('disabled')
                }else{
                    //if($("#mark_3").attr("checked")){
                    if($('#mark label input:checked').val()==3){
                        //$("#mark_0").removeAttr('checked');
                        $("#mark_0").attr('checked','checked');
                        $("#tips").hide();
                    }
                    $("#mark_3").attr('disabled','disabled');
                }
				
				if(v==1){
                    $("#swf_area").show();
                }else{
                    $("#swf_area").hide();
                }
				
            })
            
            $("#mark label input").on('change',function(){
                var v=$(this).val();
                if(v==3){
                    $("#tips").show();
                }else{
                    $("#tips").hide();
                }
            })
			

            
            $("#swftype label").on('click',function(){
                var v=$("input",this).val();
                var b=$("#swftype_bd_"+v);
                b.siblings().hide();
                b.show();
            })

            <if condition="$data['swftype'] eq '1'">
                //svga播放
                var player = new SVGA.Player('#demoCanvas');
                var parser = new SVGA.Parser('#demoCanvas'); // 如果你需要支持 IE6+，那么必须把同样的选择器传给 Parser。
                
                parser.load("{:get_upload_path($data['swf'])}", function(videoItem) {
                    player.setVideoItem(videoItem);
                    player.startAnimation();
                })
            </if>
        })()

    </script>
</body>
</html>